package com.atguigu.scala.chapter11

import scala.beans.BeanProperty

/**
 * @author lizikuan
 * @date 2021/5/25 20:31
 */
object $05_GenericContext {
  class Student[T](@BeanProperty var name:String)

  def m1[T](x:String)(implicit stu:Student[T]) ={
    stu.setName(x)
    println(stu.getName)
  }

  def m2[T:Student](x:String)={
    val stu = implicitly[Student[T]]
    stu.setName(x)
    println(stu.getName)
  }

  def main(args: Array[String]): Unit = {
    implicit val stu1 = new Student[String]("1111")
    m1[String]("zhangfei")
    m2[String]("liubei")
  }

}
